﻿using System;
namespace CSExample {


	[MyAttribute ("huilefei", "hulefei description")]
	public class AttributeDemo {
		
		public AttributeDemo () {

		}

		public static void Run () {
			Type type = typeof (AttributeDemo);
			object[] attrs = type.GetCustomAttributes (true);
			foreach (Attribute a in attrs) {
				MyAttribute myAttribute = (MyAttribute)a;
				Console.WriteLine (myAttribute.Name + "-" + myAttribute.Description);
			}
		}

		[AttributeUsage (AttributeTargets.Class |
   				 AttributeTargets.Constructor |
		                 AttributeTargets.Field |
		                 AttributeTargets.Method |
		                 AttributeTargets.Property,
		                 AllowMultiple = true)]
		public class MyAttribute : System.Attribute {
			private string name;
			private string description;

			public string Name { get { return name; } }
			public string Description { get { return description; } }
			//public string Description () { get { return description; } }

			public MyAttribute (string name, string description) {
				this.name = name;
				this.description = description;
			}
		}
	}



}

